import pymysql


class sql(object):

    # def select_sql(self,sql):
    #     conn = None
    #     cursor = None
    #     try:
    #         conn =pymysql.connect(host="211.103.136.244",port="7061",user="student",password="iHRM_student_2022",database="ihrm",charset="utf8")
    #         cursor = conn.cursor()
    #         cursor.execute(sql)
    #
    #         print("执行成功")
    #     except Exception as err:
    #         print("执行失败")
    #         cursor.close()
    #         conn.close()
    #
    #     finally:
    #         cursor.close()
    #         conn.close()
    def idu_sql(self,sql):
        conn = None
        cursor = None
        try:
            conn= pymysql.connect(host="211.103.136.244",port="7061",user="student",password="iHRM_student_2022",database="ihrm",charset="utf8")
            cursor = conn.cursor()
            cursor.execute(sql)
            print("执行成功")

            conn.commit()
        except Exception as err:
            print("执行失败",err)
            conn.rollback()
        finally:
            cursor.close()
            conn.close()



